<html>
<head><meta charset="utf-8"><title>I-prioritize #78477 BTree&#x27;s `insert_fit` breaks pointer pro… · t-compiler/wg-prioritization/alerts · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/index.html">t-compiler/wg-prioritization/alerts</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html">I-prioritize #78477 BTree&#x27;s `insert_fit` breaks pointer pro…</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214822109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214822109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214822109">(Oct 28 2020 at 11:14)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="3111">@WG-prioritization/alerts</span> issue <a href="https://github.com/rust-lang/rust/issues/78477">#78477</a> has been requested for prioritization.</p>
<h1><a href="https://forge.rust-lang.org/compiler/prioritization/procedure.html#assign-priority-to-unprioritized-issues-with-i-prioritize-label">Procedure</a></h1>
<ul>
<li>Priority?</li>
<li>Regression?</li>
<li>Notify people/groups?</li>
<li>Needs <code>I-nominated</code>?</li>
</ul>



<a name="214822388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214822388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hameer Abbasi <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214822388">(Oct 28 2020 at 11:17)</a>:</h4>
<p><code>P-high</code>/<code>P-critical</code>?</p>



<a name="214822401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214822401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hameer Abbasi <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214822401">(Oct 28 2020 at 11:17)</a>:</h4>
<p>It's unsoundness in the stdlib.</p>



<a name="214823588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214823588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214823588">(Oct 28 2020 at 11:29)</a>:</h4>
<p>I'm slightly in favor of <code>P-high</code> considering that there is a patch already on the way for this.</p>
<p>Also, probably dumb and unrelated question: does unsafe code has a weight on the priority? As in: unsafe code is unsafe so to a certain extend unsound behaviours are expected (?). I'm still confused about the expectations of unsafe code</p>



<a name="214823729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214823729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hameer Abbasi <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214823729">(Oct 28 2020 at 11:31)</a>:</h4>
<p>That's a good question. If the unsoundness can be triggered by compiling or by running anything included in the <code>stdlib</code> <em>without</em> any <code>unsafe</code> in user code, then yes, I'd say a higher priority is warranted.</p>



<a name="214827136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214827136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214827136">(Oct 28 2020 at 12:10)</a>:</h4>
<p><code>p-high</code> seems good, I am doubtful that this unsoundness causes miscompilations rn so I don't think this is <code>P-critical</code></p>



<a name="214827849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214827849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214827849">(Oct 28 2020 at 12:18)</a>:</h4>
<p>I do not fully get the question posed by <span class="user-mention silent" data-user-id="250987">apiraino</span>. unsafe code has to always be correct as long as all invariants are upheld. Unsafe functions can propagate some of these invariants to their caller but must also not cause UB if used correctly.</p>
<p>I personally do not think that it matters whether the user code which can trigger unsoundness in std uses unsafe code or not, as long as the unsafe code upholds all the requirements listed in stds documentation.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="sd">/// has to be greater than 0</span>
<span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">gt_zero</span><span class="p">(</span><span class="n">x</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">std</span>::<span class="n">hint</span>::<span class="n">unreachable_unchecked</span><span class="p">()</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">checked_gt_zero</span><span class="p">(</span><span class="n">x</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">assert_ne</span><span class="o">!</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">         </span><span class="k">return</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">std</span>::<span class="n">hint</span>::<span class="n">unreachable_unchecked</span><span class="p">()</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="214827971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214827971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214827971">(Oct 28 2020 at 12:18)</a>:</h4>
<p>^ i expect us to treat the unsoundness in both of the above functions equally</p>



<a name="214828446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214828446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214828446">(Oct 28 2020 at 12:24)</a>:</h4>
<p>ah thanks a lot for the explaination! Yes, now I understand it better in terms of unsafe != random clearly wrong behaviour.</p>



<a name="214882473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214882473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214882473">(Oct 28 2020 at 18:56)</a>:</h4>
<p>Issue <a href="https://github.com/rust-lang/rust/issues/78477">#78477</a>'s prioritization request has been removed.</p>



<a name="214954665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize%20%2378477%20BTree%27s%20%60insert_fit%60%20breaks%20pointer%20pro%E2%80%A6/near/214954665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/245100-t-compiler/wg-prioritization/alerts/topic/I-prioritize.20.2378477.20BTree&#x27;s.20.60insert_fit.60.20breaks.20pointer.20pro.E2.80.A6.html#214954665">(Oct 29 2020 at 11:34)</a>:</h4>
<p>lowering to <code>P-medium</code> after <span class="user-mention silent" data-user-id="120791">RalfJ</span>'s comment</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>